﻿using System.Windows.Forms;
using Report.Entity;
using Report.Service;

namespace Report.UI
{
    public partial class MainForm : Form
    {
        readonly GomezService gomezService;

        public MainForm()
        {
            InitializeComponent();

            gomezService = new GomezService();
            //gomezService.Login();
        }

        private void RefreshTestButtonClick(object sender, System.EventArgs e)
        {
            GomezTestCollection gomezTestCollection = gomezService.LoadTest();
            foreach (GomezTest gomezTest in gomezTestCollection.GomezTest)
            {
                TreeNode[] treeNodes = gomezTestTreeView.Nodes.Find(gomezTest.mbgMBG_ID, false);
                TreeNode parentNode = treeNodes.Length==0 ? gomezTestTreeView.Nodes.Add(gomezTest.mbgMBG_ID, gomezTest.mbgName) : treeNodes[0];
                parentNode.Nodes.Add(gomezTest.mbgmMBGMonitor_ID, gomezTest.mDescription);
            }
        }
    }
}
